package com.wonder.dto;

public class DoublePoint {

    // 双指针算法
    // 1,2,3,3,3,4,4,4,5,6
    // 2,3,3,3

    public static int removeDuplicates(int[] nums){
        if (nums.length == 0){
            return 0;
        }
        int i =0;
        for (int j = 1;j < nums.length;j++){
            if (nums[j] != nums[i]){
                i++;
                nums[i] = nums[j];
            }
        }

        return i+1;
    }


    public static void main(String[] args) {
        int[] nums = new int[]{1,2,3,3,3,4,4,4,5,5,5,5,6,6,7};

        System.out.printf("remove = "+removeDuplicates(nums));
    }
}
